# -*- coding: UTF-8 -*- 
from django.db import models
from django.contrib.auth.models import User
import datetime

class UserProfile(models.Model):
    GENDER_CHOICES = (
        ('M', u'男'),
        ('F', u'女'),
    )
    
    user = models.ForeignKey(User, unique=True)
    gender = models.CharField(max_length=1, choices=GENDER_CHOICES)
    birthday = models.DateField()
    hometown = models.CharField(max_length=128, default=u'')
    qq = models.CharField(max_length=15, default=u'')
    msn = models.EmailField(default=u'')
    gtalk = models.EmailField(default=u'')
    phone_number = models.CharField(max_length=50, default=u'')
    website = models.URLField(default=u'')
    logo = models.ImageField(upload_to="./upload", height_field=80, width_field=80)
    status = models.CharField(max_length=72, default=u'')
    last_update_status = models.DateTimeField(default=datetime.datetime.now)
    is_online = models.BooleanField(default=False)
    
    class Meta:
        db_table = 'user_profile'
        
    def get_big_logo(self):
        return self.logo.name.replace('50x50', '200x200')
    
    def get_normal_logo(self):
        return self.logo.name.replace('50x50', '150x150')
    
class Resume(models.Model):
    '''表示用户的履历'''
    user = models.ForeignKey(User)
    type = models.SmallIntegerField()         #It is a enumerator: 1. education 2. work history
    start_date = models.DateField()
    end_date = models.DateField()
    place = models.CharField(max_length=128)  #School or company
    department = models.CharField(max_length=128) #Major or job department
    position = models.CharField(max_length=128) #Degree or working position
    
    class Meta:
        db_table = 'resume'